# list_functions.py
#
# Functions to manipulate lists that are not necessarily provided by python

import unittest

def shiftListLeft(list, shift):
    return map(lambda index: list[(index+shift)%len(list)], range(len(list)))

def shiftListRight(list, shift):
    return map(lambda index: list[(index-shift)%len(list)], range(len(list)))

if __name__ == '__main__':
    class TestListFunctions(unittest.TestCase):

        def test_shift_list_left(self):
            list = [0, 1, 2]
            self.assert_(shiftListLeft(list, 1) == [1, 2, 0])
            self.assert_(shiftListLeft(list, 2) == [2, 0, 1])
            self.assert_(shiftListLeft(list, 3) == [0, 1, 2])

        def test_shift_list_right(self):
            list = [0, 1, 2]
            self.assert_(shiftListRight(list, 1) == [2, 0, 1])
            self.assert_(shiftListRight(list, 2) == [1, 2, 0])
            self.assert_(shiftListRight(list, 3) == [0, 1, 2])

    unittest.main()
